package com.woniuxy01;

import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-07-16 9:36
 */
public class Test07 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入运算数");
        int numA = sc.nextInt();
        System.out.println("输入运算数");
        int numB = sc.nextInt();
        System.out.println("输入运算符+-*/");
        String opeartor = sc.next();
        int result = 0;
        //operatorFlag---true运算符有效
        boolean operatorFlag = true;
        //divideFlag---true除数不为0，可以进行除法运算
        boolean divideFlag = true;
        switch (opeartor) {
            case "+":
                result = numA + numB;
                break;
            case "-":
                result = numA - numB;
                break;
            case "*":
                result = numA * numB;
                break;
            case "/":
                if (numB != 0) {
                    result = numA / numB;
                } else {
                    divideFlag = false;
                }
                break;
            default:
                operatorFlag = false;
                break;
        }


        //统一输出
        if (operatorFlag) {
            if (!divideFlag) {
                System.out.println("除数不能为0");
            } else {
                System.out.println("运算结果是：" + numA + opeartor + numB + "=" + result);
            }
        } else {
            System.out.println("无效运算符，无法计算");
        }
    }
}
